![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
phosphor-boxengine
Advanced tools
A low-level box layout algorithm.
Prerequisites
npm install --save phosphor-boxengine
Prerequisites
git clone https://github.com/phosphorjs/phosphor-boxengine.git
cd phosphor-boxengine
npm install
Rebuild
npm run clean
npm run build
Follow the source build instructions first.
npm test
Follow the source build instructions first.
npm run docs
Navigate to docs/index.html
.
The runtime versions which are currently known to work are listed below. Earlier versions may also work, but come with no guarantees.
Follow the package install instructions first.
npm install --save-dev browserify
browserify myapp.js -o mybundle.js
Note: This module is fully compatible with Node/Babel/ES6/ES5. Simply omit the type declarations when using a language other than TypeScript.
import {
BoxSizer, boxCalc
} from 'phosphor-boxengine';
// Setup a simple 3-column arrangement. Normally done via static HTML
// or some form of DOM generation library. Kept simple for this example.
let host = document.createElement('div');
let col1 = document.createElement('div');
let col2 = document.createElement('div');
let col3 = document.createElement('div');
let columns = [col1, col2, col3];
host.style.position = 'relative';
host.style.height = '500px';
col1.style.position = 'absolute';
col1.style.top = '0';
col1.style.bottom = '0';
col2.style.position = 'absolute';
col2.style.top = '0';
col2.style.bottom = '0';
col3.style.position = 'absolute';
col3.style.top = '0';
col3.style.bottom = '0';
host.appendChild(col1);
host.appendChild(col2);
host.appendChild(col3);
document.body.appendChild(host);
// Create the sizers for the columns.
let sizer1 = new BoxSizer();
let sizer2 = new BoxSizer();
let sizer3 = new BoxSizer();
let sizers = [sizer1, sizer2, sizer3];
// Setup the constraints on the column widths.
sizer1.minSize = 150;
sizer2.maxSize = 250;
sizer2.minSize = 100;
sizer3.minSize = 150;
sizer3.maxSize = 250;
// Setup the desired sizes for the columns.
sizer1.sizeHint = 300;
sizer2.sizeHint = 600;
sizer3.sizeHint = 200;
// The middle column expands twice as fast as the others.
sizer1.stretch = 1;
sizer2.stretch = 2;
sizer3.stretch = 1;
// Layout the columns on each resize event. Note that `boxCalc` only
// handles sizes in the direction of layout (`width` in this case).
// The application decides how to handle the orthogonal dimension.
window.onresize = () => {
// Compute the new column sizes for the host width.
boxCalc(sizers, host.offsetWidth);
// Layout the columns using the computed sizes.
let left = 0;
for (let i = 0; i < sizers.length; ++i) {
let col = columns[i];
let sizer = sizers[i];
col.style.left = left + 'px';
col.style.width = sizer.size + 'px';
left += sizer.size;
}
};
FAQs
A low-level box layout algorithm.
The npm package phosphor-boxengine receives a total of 0 weekly downloads. As such, phosphor-boxengine popularity was classified as not popular.
We found that phosphor-boxengine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.